<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal"
	scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

	<%@ include file="/WEB-INF/include/header.jsp"%>
	<%@ include file="/WEB-INF/include/submenu.jsp"%>

	<div class="container-fluid ms-container has-ms-sidemenu">

		<ol class="ms-breadcrumb breadcrumb">
			<li class="active">财务报表&nbsp;-&nbsp;报表查询</li>
		</ol>

		<div class="ms-content-layout has-operation">
			<div class="x-operation-bar no-margin no-bottom-border clearfix">
				<div class="ms-operation-bar no-margin no-bottom-border clearfix">
					<div class="ms-operation-group">
						<div class="pull-right">
							<a href="${ctx.host}/reports/search" data-target="#search"
								data-toggle="modal" class="btn ms-btn ms-btn-blue"> <i
								class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
							</a>
						</div>
					</div>
				</div>
				<table class="table table-hover ms-table">
					<thead>
						<tr>
							<th>订单号</th>
							<th>alamo订单号</th>
							<th>下单时间</th>
							<th>取还车时间</th>
							<th>国家</th>
							<th>品牌</th>
							<th>到付/预付</th>
							<th>订单金额(美金)</th>
							<th>成本价(美金)</th>
							<th>API价格</th>
							<th>订单优惠金额(人民币)</th>
							<th>汇率</th>
							<th>代理</th>
							<th>订单状态</th>
							<th class="text-center">操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${orders}" var="orders">
							<tr>
								<td>${orders.code}</td>
								<td>${orders.alamoCode}</td>
								<td><fmt:formatDate value="${orders.createTime}"
										pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td><fmt:formatDate value="${orders.pickupDate}"
										pattern="yyyy-MM-dd HH:mm" /><br /> <fmt:formatDate
										value="${orders.returnDate}" pattern="yyyy-MM-dd HH:mm" /></td>
								<td>${persist.country(orders.country).chineseName}</td>
								<td>${persist.supplier(orders.brand).chineseName}</td>
								<td>${orders.type.description}</td>
								
								<td>
								    <fmt:formatNumber pattern="0.00" value="${orders.decimalPayPrice}"></fmt:formatNumber>
								</td>
								<td>
								    <fmt:formatNumber value="${orders.bigDecimalCostPrice}" pattern="0.00" type="number" />
								</td>
                                <td>
                                    <fmt:formatNumber value="${orders.decimalTotalAmount}" pattern="0.00" type="number" />
                                </td>
								<td>
									<c:if test="${! empty orders.userCouponId}">
										<fmt:formatNumber value="${persist.loadCnyPrice(orders.id) < 0 ? '0.00':persist.loadCnyPrice(orders.id)}" type="number"   maxFractionDigits="2" pattern="0.00" />
									</c:if>
								</td>
								<td>${orders.currentExchangeRate}</td>

								<td>${orders.agent.name}</td>
								<td>${orders.status.description}</td>
								<td><a href="${ctx.host}/reports/${orders.id}">详情</a></td>
							</tr>

						</c:forEach>
					</tbody>

					<tfoot>
						<tr>
							<td colspan="15" class="no-vertical-padding">
								<div class="pull-left">
									<jsp:include page="/WEB-INF/include/page.jsp">
										<jsp:param name="url" value="${ctx.host}/reports" />
										<jsp:param name="queryString" value="${queryString}" />
									</jsp:include>
								</div>
							
								<div class="pull-right">
									<c:if test="${page.totals > 0}">
										<a href="${ctx.host}/reports/report-export?${queryString}&per_page=${config.everyPage}&page=${page.currentPage}" class="btn btn-default ms-export">输出当前记录</a>
										<a href="${ctx.host}/reports/report-export?${queryString}&per_page=${config.limit}&page=1" class="btn btn-default ms-export">输出所有记录</a>
									</c:if>
								</div>
							</td>
						</tr>
					</tfoot>
				</table>


			</div>


		</div>
	</div>
	<%@ include file="/WEB-INF/include/footer.jsp"%>
	<%@ include file="/WEB-INF/include/script.jsp"%>

	<d:resource type="script" root="${ctx.resource}/build" src="js/page/report/report-list.js" />
	<script type="text/javascript">
		require([ 'page/report/report-list' ], function(page) {
			page.init()
		})
	</script>
</body>
</html>